#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
struct node{
	string id;
	int price,people;
};
int main(){
	int n;
	string id;
	cin >> n;
	vector<node> list(n);
	int max = 0,max2 = 0;
	for(int i = 0;i < n;i++){
		cin >> list[i].id >> list[i].price >> list[i].people;
	}
	for(int i = 1;i < n;i++){
		if(list[i].people>list[max].people) max = i;
		if(list[i].people*list[i].price>list[max2].people*list[max2].price) max2 = i;
	}
	cout << list[max].id << " " << list[max].people << endl;
	cout << list[max2].id << " " << list[max2].people*list[max2].price << endl;
	return 0;
}
